#!/home/y/bin/perl

use FindBin qw/$Bin/;
use lib qw(lib ../lib);
use Data::Dumper qw(Dumper);
use Test::More qw/no_plan/;

use_ok('Farsail::Action');

my $actions = {
    greet => {
        module => 'Greeting',
        args_type => {
            my_date => { type => 'date', default => 'yesterday' },
        },
        hello => {
            depends => ['find_somebody'],
            args => { date => 'my_date' },
        },
        find_somebody => {
            module => "WalkAround",
        },
    },
};

my $action = Farsail::Action->new($actions->{greet}, 'greet', 'hello');

isa_ok($action, 'Farsail::Action');
is($action->namespace, 'greet');
is($action->name, 'hello');
is($action->full_name, 'greet.hello');
ok($action->parent == $actions->{greet});
is($action->module, $actions->{greet}{module});
is_deeply([$action->depends], ['greet.find_somebody']);
is_deeply($action->args,
          {
              date => { type => 'date', default => 'yesterday' },
          }
      );

$action = Farsail::Action->new($actions->{greet}, 'greet', 'find_somebody');
is($action->module, 'WalkAround');
